	.msfirst
PIA_A	equ	$F000
CON_A	equ	$F001
PIA_B	equ	$F002
CON_B	equ	$F003

ACIA_ATXM	equ	$F004
ACIA_ARCX	equ	ACIA_ATXM
ACIA_ASTS	equ	$F005
ACIA_ARES	equ	ACIA_ASTS
ACIA_ACMD	equ	$F006
ACIA_ACTL	equ	$F007


	ORG	$2000

MAIN:	LDS	$007F		; RESET STACK POINTER

; initialize ACIA
	STA	ACIA_ARES	; SOFT RESET
	LDA	#$0B		; SET SPECIFIC MODES AND FUNCTIONS
	STA	ACIA_ACMD
	LDA	#$1E		; 8-N-1, 9600 BPS
	STA	ACIA_ACTL

typewriter0:
	LDA	ACIA_ASTS
	ANDA	#$08		; RXM DATA REGISTER FULL?
	BEQ	typewriter0	; 1=FULL, 0=NOT FULL

	LDAB	ACIA_ARCX	; GET DATA FROM RECEIVE IN B REGISTER

typewriter1:
	LDA	ACIA_ASTS
	ANDA	#$10		; TXM DATA REGISTER EMPTY?
	BEQ	typewriter1	; 1=EMPTY, 0=NOT EMPTY

	TBA			; RETRIEVE DATA TO SEND FROM B REGISTER
	STA	ACIA_ATXM	; SEND TO TRANSMITTER
	BRA	typewriter0	; DO AGAIN FOREVER

	END
